package CavReaderExample;

import java.io.*;
import java.util.*;

public class ReadCSV {

	public void parse(String filename) {
		Collection<String> lines = new ArrayList<String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(new File(filename)));
			String line;
			while ((line = br.readLine()) != null) {
				int jeda = line.indexOf(";");		
				String isi = line.substring(0, jeda);
				//lines.add(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		printLines(lines);
		System.out.println("\n\n-----------------\n\n");
		printRecords(lines);
	}
	
	private void printLines(Collection<String> lines) {
		for (String line : lines) {
			System.out.println(line);
		}
	}
	
	private void printRecords(Collection<String> lines) {
		for (String line : lines) {
			String[] recordsOnLine = line.split(",");
			for (String record : recordsOnLine) {
				System.out.println(record);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new ReadCSV().parse("test.csv");
	}
}
